package filter01;

import jakarta.servlet.*;

import java.io.IOException;

public class FilterDemo01 implements Filter {

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("FilterDemo01开始执行"+servletRequest+"..."+servletResponse);

        filterChain.doFilter(servletRequest,servletResponse);//一旦执行这个方法 就相当于过滤器放行 去访问目标资源

        System.out.println("FilterDemo01结束执行");
        servletResponse.setContentType("text/html;charset=UTF-8");
        servletResponse.getWriter().write("FilterDemo01的响应");

    }
}
